#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e6 + 5;

int n, m;
bool vis[N * 3];
void init_primes(int n) {
  vis[1] = 1;
  for (ll i = 2; i * i <= n; i++) {
    if (!vis[i])
      for (ll j = i * i; j <= n; j += i) vis[j] = 1;
  }
}
int cnt[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  init_primes(3e6 + 7);
  rep(i, 1, 1e6) cnt[i] = cnt[i - 1] + (!vis[i * 3 + 7] ? 1 : 0);
  int t;
  cin >> t;
  while (t--) {
    int x;
    cin >> x;
    cout << cnt[x] << endl;
  }
  return 0;
}